/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package controllers;

import models.*;

/**
 *
 * @author ezubia
 */

public class Security extends Secure.Security {
    
    static boolean authenticate(String username, String password){
    return User.connect(username, password) !=null;
    }
    
    static void onDiscnnected() {
        Application.index();
    }
    static void onAuthenticated() {
        Admin.index();
    }

    static boolean check(String porfile){
        if("admin".equals(porfile)){
            return User.find("byEmail", connected()).<User>first().isAdmin;
        }return false;
    }
    
}
